package LeetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Kechelle
 * @Date 2020/9/21 9:17
 * @Version 1.0
 */
public class Code401 {
    public List<String> readBinaryWatch(int num){
        List<String> times = new ArrayList<>();
        for (int i=0;i<12;i++){
            for (int j=0;j<60;j++){
                if (Integer.bitCount(i) + Integer.bitCount(j) == num){
                    times.add(format(i,j));
                }
            }
        }
        return times;
    }

    public String format(int i,int j){
        StringBuilder builder = new StringBuilder();
        builder.append(i + ":");
        if (j<10){
            builder.append(0);
        }
        builder.append(j);
        return builder.toString();
    }

    public static void main(String[] args) {
        Code401 test = new Code401();
        System.out.println(test.readBinaryWatch(2));
    }
}
